﻿//页面加载
$(document).ready(function () {
    // $("#btnSave").bind("click", btnSave_click);
    $("#fmSave").bind("submit", btnSave_click);
    $("#btnCancel").bind("click", btnCancel_click);
})

function btnSave_click(e) {
    //异步提交表单,表单中input元素必须设置name 属性
    e.preventDefault();

    //异步提交带文件上传的表单
    var formURL = "/Template/Save";
    var formData = new FormData(this);
    $.ajax({
        url: formURL,
        type: "POST",
        data: formData,
        mimeType: "multipart/form-data",
        contentType: false,
        cache: false,
        processData: false,
        success: function (result) {
            if (result.code == "OK") {
               alert("数据保存成功!")
               window.location.href = "/Template/Index";     
            }
            else {
                alert("出现错误：" + result.msg);
            }
        }
        ,
        dataType: "json"
    });
}

function btnCancel_click() {
    window.history.go(-1);
}